﻿using System;
using ThinkGeo.MapSuite.Core;
using ThinkGeo.MapSuite.WebEdition;  

namespace NghiSonStyle.KCN.KCN
{
    public partial class KCN1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF"));
                Map1.CurrentExtent = new RectangleShape(105.71091,19.34982, 105.78240, 19.34982);
                Map1.MapUnit = GeographyUnit.DecimalDegree;
                Map1.MapTools.MouseCoordinate.Enabled = true;

               // WorldMapKitWmsWebOverlay worldMapKitOverlay = new WorldMapKitWmsWebOverlay();
                //Map1.CustomOverlays.Add(worldMapKitOverlay);

               // ShapeFileFeatureSource.BuildIndexFile(MapPath("~/Data/KCN/CN1/MuongNuoc_PLL.shp"), BuildIndexMode.Rebuild);
                ShapeFileFeatureSource.BuildIndexFile(MapPath("~/Data/KCN/CN1/TramDienHienCo_P.shp"), BuildIndexMode.Rebuild);

                //PLL Đường bao
                ShapeFileFeatureLayer NhaMayKhoTangPLL = new ShapeFileFeatureLayer(MapPath("~/Data/KCN/CN1/DatNhaMayKhoTang_PLL.shp"));
                ShapeFileFeatureLayer CayXanhPLL = new ShapeFileFeatureLayer(MapPath("~/Data/KCN/CN1/DatCayXanh_PLL.shp"));
                ShapeFileFeatureLayer MuongNuocPLL = new ShapeFileFeatureLayer(MapPath("~/Data/KCN/CN1/MuongNuoc_PLL.shp"));
                NhaMayKhoTangPLL.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.FromHtml("#171B39"), 2, GeoColor.FromHtml("#FFB2E8"), 0, true);
                NhaMayKhoTangPLL.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
                CayXanhPLL.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.FromHtml("#171B39"), 1, GeoColor.FromHtml("#FFB2E8"), 0, true);
                CayXanhPLL.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
                MuongNuocPLL.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.FromHtml("#171B39"), 1, GeoColor.FromHtml("#FFB2E8"), 0, true);
                MuongNuocPLL.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

                //TimDuong
                ShapeFileFeatureLayer Nettimduong_polyline = new ShapeFileFeatureLayer(MapPath("~/Data/KCN/CN1/TimDuong_L.shp"));
                Nettimduong_polyline.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.StateBorder1;
                Nettimduong_polyline.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

                //Huong Duong L
                ShapeFileFeatureLayer HuongDuongL = new ShapeFileFeatureLayer(MapPath("~/Data/KCN/CN1/HuongDuong_L.shp"));
                HuongDuongL.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.FromHtml("#353541"), 1, GeoColor.FromHtml("#FFB2E8"), 0, true);
                HuongDuongL.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

                //RanhGioiQuyHoach
                ShapeFileFeatureLayer RanhGioiQuyHoachL = new ShapeFileFeatureLayer(MapPath("~/Data/KCN/CN1/RanhGioiQuyHoach_L.shp"));
                RanhGioiQuyHoachL.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.FromHtml("#D7412B"), 3, LineDashStyle.Dash, true);
                RanhGioiQuyHoachL.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
                //RanhGioiDuAn
                ShapeFileFeatureLayer RanhGioiDuAnL = new ShapeFileFeatureLayer(MapPath("~/Data/KCN/CN1/RanhGioiDuAn_L.shp"));
                RanhGioiDuAnL.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.FromHtml("#D7412B"), 1, LineDashStyle.DashDot, true);
                RanhGioiDuAnL.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
                //Duong Dien
                ShapeFileFeatureLayer DuongDienL = new ShapeFileFeatureLayer(MapPath("~/Data/KCN/CN1/DuongDien110KV_L.shp"));
                DuongDienL.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.Equator1;
                DuongDienL.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
                //Duong Sat
                ShapeFileFeatureLayer DuongSatL = new ShapeFileFeatureLayer(MapPath("~/Data/KCN/CN1/DuongSatDuKien_L.shp"));
                DuongSatL.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.Railway1;
                DuongSatL.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
                

                //Dat Nhà máy kho tàng
                ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(MapPath("~/Data/KCN/CN1/DatNhaMayKhoTang_PLG.shp"));
                AreaStyle areaStyle = new AreaStyle();
                areaStyle.Advanced.FillCustomBrush = new GeoTextureBrush(new GeoImage(MapPath("~/Images/NhaMay.jpg")), GeoWrapMode.TileFlipXY);
               // TextStyle lable = new TextStyle();
               // lable.YOffsetInPixel = 5;
               // lable.Advanced.TextCustomBrush= TextStyles.CreateSimpleTextStyle("Name", "Arial", 10, DrawingFontStyles.Regular, GeoColor.StandardColors.Black);
                worldLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(TextStyles.CreateSimpleTextStyle("Name", "Arial", 10, DrawingFontStyles.Regular, GeoColor.StandardColors.Black));
                worldLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(areaStyle);            
                worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

                //Dat cong trinh dau moi
                ShapeFileFeatureLayer congtrinhdaumoi = new ShapeFileFeatureLayer(MapPath("~/Data/KCN/CN1/DatCongTrinhDauMoi_PLG.shp"));
                AreaStyle areaStyle5 = new AreaStyle();

                areaStyle5.Advanced.FillCustomBrush = new GeoTextureBrush(new GeoImage(MapPath("~/Images/DatCongTrinhDauMoi.jpg")), GeoWrapMode.TileFlipXY);
            
                congtrinhdaumoi.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(areaStyle5);
                
                //congtrinhdaumoi.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.Capital1("Name");  
                congtrinhdaumoi.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
                congtrinhdaumoi.DrawingMarginPercentage = 50;  
                //Dat CayXanh
                ShapeFileFeatureLayer DatCayXanhPLG = new ShapeFileFeatureLayer(MapPath("~/Data/KCN/CN1/DatCayXanhHanhLang_PLG.shp"));
                AreaStyle areaStyle1 = new AreaStyle();
                areaStyle1.Advanced.FillCustomBrush = new GeoTextureBrush(new GeoImage(MapPath("~/Images/CayXanh.jpg")), GeoWrapMode.TileFlipXY);
                DatCayXanhPLG.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(areaStyle1);            
                DatCayXanhPLG.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

                //Dat DV Cong Nghiep
                ShapeFileFeatureLayer DatDVCNPLG = new ShapeFileFeatureLayer(MapPath("~/Data/KCN/CN1/DatDVCongNghiep_PLG.shp"));
                AreaStyle areaStyle4 = new AreaStyle();
                areaStyle4.Advanced.FillCustomBrush = new GeoTextureBrush(new GeoImage(MapPath("~/Images/DatDichVu.jpg")), GeoWrapMode.TileFlipXY);
                DatDVCNPLG.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(areaStyle4);
                DatDVCNPLG.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

                //Dat MuongNuoc
                ShapeFileFeatureLayer MuongNuocPLG = new ShapeFileFeatureLayer(MapPath("~/Data/KCN/CN1/MuongNuoc_ThuyLoi_PLG.shp"));
                AreaStyle areaStyle2 = new AreaStyle();
                areaStyle2.Advanced.FillCustomBrush = new GeoTextureBrush(new GeoImage(MapPath("~/Images/AoHo.jpg")), GeoWrapMode.TileFlipXY);
                MuongNuocPLG.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(areaStyle2);
                MuongNuocPLG.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

                //Dat Duong
                ShapeFileFeatureLayer LongDuongPLG = new ShapeFileFeatureLayer(MapPath("~/Data/KCN/CN1/LongDuong_PLG.shp"));
                //AreaStyle areaStyle2 = new AreaStyle();
                //areaStyle2.Advanced.FillCustomBrush = new GeoTextureBrush(new GeoImage(MapPath("~/Images/AoHo.jpg")), GeoWrapMode.TileFlipXY);
                LongDuongPLG.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromHtml("#353541"), GeoColor.FromArgb(255, 132, 132, 154), 0);
                LongDuongPLG.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

                //Dat Giai Phan Cah
                ShapeFileFeatureLayer GiaiPhanCachPLG = new ShapeFileFeatureLayer(MapPath("~/Data/KCN/CN1/GiaiPhanCachGiuaDuong_PLG.shp"));
                AreaStyle areaStyle3 = new AreaStyle();
                areaStyle3.Advanced.FillCustomBrush = new GeoTextureBrush(new GeoImage(MapPath("~/Images/GiaiPhanCach.jpg")), GeoWrapMode.TileFlipXY);
                GiaiPhanCachPLG.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(areaStyle3);
                GiaiPhanCachPLG.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

                ShapeFileFeatureLayer TieuCanh_Point = new ShapeFileFeatureLayer(MapPath("~/Data/KCN/CN1/TramDienHienCo_P.shp"));
                TieuCanh_Point.ZoomLevelSet.ZoomLevel18.DefaultPointStyle = new PointStyle(new GeoImage(Server.MapPath("~/Images/TramDien1_icon.png")));
                TieuCanh_Point.ZoomLevelSet.ZoomLevel18.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
        
                LayerOverlay staticOverlay = new LayerOverlay();
                staticOverlay.IsBaseOverlay = false;
                staticOverlay.Layers.Add(worldLayer);
                staticOverlay.Layers.Add(DatCayXanhPLG);
                staticOverlay.Layers.Add(congtrinhdaumoi);
                staticOverlay.Layers.Add(MuongNuocPLG);
                staticOverlay.Layers.Add(NhaMayKhoTangPLL);
                staticOverlay.Layers.Add(LongDuongPLG);
                staticOverlay.Layers.Add(GiaiPhanCachPLG);
                staticOverlay.Layers.Add(DatDVCNPLG);
                staticOverlay.Layers.Add(CayXanhPLL);
                staticOverlay.Layers.Add(MuongNuocPLL);
                staticOverlay.Layers.Add(Nettimduong_polyline);
                staticOverlay.Layers.Add(RanhGioiQuyHoachL);
                staticOverlay.Layers.Add(RanhGioiDuAnL);
                staticOverlay.Layers.Add(DuongSatL);
                staticOverlay.Layers.Add(DuongDienL);
                staticOverlay.Layers.Add(HuongDuongL);
                staticOverlay.Layers.Add(TieuCanh_Point);

                Map1.CustomOverlays.Add(staticOverlay);
            }  
        }
    }
}